home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / Examples / Mixing / Watchtv / library / TVBounce2 < prev   
Encoding:
INI File  |  2001-09-10  |  1.3 KB  |  47 lines

  1. [Name]
  2. Bounce - Allows Sprite to bounce like a ball
  3. Written by Steve Israelson (modified by Greg Gilman)
  4.  
  5. [Description]
  6. The sprite will move and bounce in an area
  7.  
  8. [Parameters]
  9. Left edge, BOUNCE_LeftEdge,1
  10. Right edge, BOUNCE_RightEdge,1
  11. Top edge, BOUNCE_TopEdge,1
  12. Bottom edge, BOUNCE_BottomEdge,1
  13. Speed, BOUNCE_Speed,1,1,10
  14. Callback, BOUNCE_EVENT,1000
  15.  
  16. [Frame Loaded]    Frame Loaded Handler
  17. SpriteVars BOUNCE_xvel BOUNCE_yvel
  18. BOUNCE_xvel = Random(1,$BOUNCE_Speed)
  19. BOUNCE_yvel = Random(1,$BOUNCE_Speed)
  20.  
  21. [Idle]            Idle Handler
  22. SpriteVars BOUNCE_xvel BOUNCE_yvel
  23.  
  24. // Move the sprite
  25. MoveBy(BOUNCE_xvel, BOUNCE_yvel)
  26.  
  27. if (BoundsLeft < $BOUNCE_LeftEdge)
  28.     MoveBy(($BOUNCE_LeftEdge - BoundsLeft), 0)
  29.     BOUNCE_xvel = -BOUNCE_xvel;
  30.     ExecuteEvent($BOUNCE_EVENT)
  31. elseif (BoundsRight > $BOUNCE_RightEdge)
  32.     MoveBy(($BOUNCE_RightEdge - BoundsRight), 0)
  33.     BOUNCE_xvel = -BOUNCE_xvel;
  34.     ExecuteEvent($BOUNCE_EVENT)
  35. endif
  36. if (BoundsTop < $BOUNCE_TopEdge)
  37.     MoveBy(($BOUNCE_TopEdge - BoundsTop), 0)
  38.     BOUNCE_yvel = -BOUNCE_yvel;
  39.     ExecuteEvent($BOUNCE_EVENT)
  40. elseif (BoundsBottom > $BOUNCE_BottomEdge)
  41.     MoveBy(($BOUNCE_BottomEdge - BoundsBottom), 0)
  42.     BOUNCE_yvel = -BOUNCE_yvel;
  43.     ExecuteEvent($BOUNCE_EVENT)
  44. endif
  45.  
  46. spritenamed("box").Moveto(spritenamed("tv").firstcornerx + 19, spritenamed("tv").firstcornery + 75) 
  47.